import {inject, lifeCycleObserver, LifeCycleObserver} from '@loopback/core';
import {juggler} from '@loopback/repository';
import {myAppConfig} from '../config/config';

// const config = {
//   name: 'training',
//   connector: 'mysql',
//   url: '',
//   host: 'mariadb-dev.k8sprd-wzs.k8s.wistron.com.cn',
//   port: 30246,
//   user: 'training',
//   password: '2020@wzs',
//   database: 'training'
// };
const config = {...myAppConfig.config};

// Observe application's life cycle to disconnect the datasource when
// application is stopped. This allows the application to be shut down
// gracefully. The `stop()` method is inherited from `juggler.DataSource`.
// Learn more at https://loopback.io/doc/en/lb4/Life-cycle.html
@lifeCycleObserver('datasource')
export class TrainingDataSource extends juggler.DataSource
  implements LifeCycleObserver {
  static dataSourceName = 'training';
  static readonly defaultConfig = config;

  constructor(
    @inject('datasources.config.training', {optional: true})
    dsConfig: object = config,
  ) {
    super(dsConfig);
  }
}
